/**
 * 作者：陈文斌 on 2019/1/23.
 * 邮箱：chen_wennbin@163.com
 * 版本：v1.0
 */

import 'package:flutter/material.dart';
import 'package:crm/constant/constant.dart';
import 'package:crm/model/Feedback/feedback_model.dart';

class UserFeedbackRecordListRowSection extends StatefulWidget {
  final FeedbackModel feedbackRecord;
  final VoidCallback onTap;

  UserFeedbackRecordListRowSection({
    Key key,
    this.feedbackRecord,
    this.onTap,
  }) : super(key: key);

  @override
  State<StatefulWidget> createState() {
    return _UserFeedbackRecordListRowSectionState();
  }
}

class _UserFeedbackRecordListRowSectionState
    extends State<UserFeedbackRecordListRowSection> {
  @override
  Widget build(BuildContext context) {
    Widget _userInfoSection({String name, String date}) {
      return Container(
        height: 21,
        alignment: Alignment.center,
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: <Widget>[
            Expanded(
              child: Row(
                children: <Widget>[
                  Expanded(
                    child: Text(
                      name,
                      style: TextStyle(
                        color: Color(0xFF353535),
                        fontSize: AppFontSizes.Font15,
                        fontFamily: AppFontFamilies.PingFangSC,
                        fontWeight: FontWeight.w700,
                      ),
                      overflow: TextOverflow.ellipsis,
                      maxLines: 1,
                    ),
                  ),
                  Padding(padding: EdgeInsets.only(left: 14)),
                  Container(
                    width: 40,
                    height: 16,
                    alignment: Alignment.center,
                    decoration: BoxDecoration(
                      borderRadius: BorderRadius.circular(2),
                      border: Border.all(color: Color(0xFFF95672), width: 1),
                    ),
                    child: Text(
                      date,
                      style: TextStyle(
                        color: Color(0xFFF95672),
                        fontSize: 11,
                        fontFamily: AppFontFamilies.PingFangSC,
                        fontWeight: FontWeight.w500,
                      ),
                    ),
                  ),
                ],
              ),
            ),
            Container(
              margin: EdgeInsets.only(left: 20),
              child: Text(
                '2018/03/18',
                style: TextStyle(
                  color: AppColors.PlaceholderTextColor,
                  fontSize: AppFontSizes.Font12,
                  fontFamily: AppFontFamilies.PingFangSC,
                  fontWeight: FontWeight.w500,
                ),
              ),
            ),
          ],
        ),
      );
    }

    Widget _phoneSection({String phone}) {
      return Container(
        height: 18,
        child: Row(
          children: <Widget>[
            Expanded(
              child: Text(
                '联系电话:${phone}',
                style: TextStyle(
                  color: AppColors.TextColor,
                  fontSize: AppFontSizes.Font13,
                  fontFamily: AppFontFamilies.PingFangSC,
                  fontWeight: FontWeight.w500,
                ),
              ),
            ),
            Container(
              width: 18,
              height: 18,
              decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(9),
                color: AppColors.MainColor,
              ),
            ),
          ],
        ),
      );
    }

    Widget _contentSection({String content, List<String> imageUrls}) {
      return Container(
        padding: EdgeInsets.fromLTRB(10, 13, 10, 13),
        color: AppColors.PageBackgroundColor,
        child: Column(
          children: <Widget>[
            Text(
              content,
              style: TextStyle(
                color: AppColors.DetailTextColor,
                fontSize: AppFontSizes.Font13,
                fontFamily: AppFontFamilies.PingFangSC,
                fontWeight: FontWeight.w500,
              ),
            ),
            Padding(padding: EdgeInsets.only(top: 10)),
            Container(
              child: GridView.count(
                shrinkWrap: true,
                primary: false,
                crossAxisSpacing: 6,
                mainAxisSpacing: 6,
                crossAxisCount: 6,
                children: <Widget>[
                  Container(
                    color: Colors.red,
                  ),
                  Container(
                    color: Colors.red,
                  ),
                  Container(
                    color: Colors.red,
                  ),
                ],
              ),
            ),
          ],
        ),
      );
    }

    Widget _processResultSection({String result}) {
      return Text(
        '处理结果：${result}',
        style: TextStyle(
          color: AppColors.MainColor,
          fontSize: AppFontSizes.Font12,
          fontFamily: AppFontFamilies.PingFangSC,
          fontWeight: FontWeight.w500,
        ),
      );
    }

    return Container(
      child: Column(
        children: <Widget>[
          Padding(padding: EdgeInsets.only(top: 10)),
          Container(
            padding: EdgeInsets.fromLTRB(16, 15, 16, 12),
            color: Colors.white,
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: <Widget>[
                _userInfoSection(
                  name: '盐城金雕服饰盐城金雕服饰盐城金雕服饰盐城金雕服饰盐城金雕服饰',
                  date: '处理中',
                ),
                Padding(padding: EdgeInsets.only(top: 10)),
                _phoneSection(phone: '0595-85585586'),
                Padding(padding: EdgeInsets.only(top: 14)),
                _contentSection(
                  content: '产品有锈渍，产品次品较多，产品有瑕疵产品次品较多。产品有瑕疵产品次品较多。',
                ),
                Padding(padding: EdgeInsets.only(top: 10)),
                _processResultSection(result: '已联系客户协商处理，免费更换残次品。'),
              ],
            ),
          ),
        ],
      ),
    );
  }
}
